﻿using MyMVC;
using Newtonsoft.Json;
using STHPMS1.Common.C_Definition;
using STHPMS1.Common.C_Entity;
using STHPMS1.Common.C_Entity.Stmpms1;
using STHPMS1.Common.C_Extension;
using STHPMS1.ICore;
using STHPMS1.ICore.I_Core;
using STHPMS1.ICore.I_UI;
using STHPMS1.Web.W_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace STHPMS1.Web.W_Service
{
    public class TestPage1Service
    {
        [Action]
        public object list(int? page,int? rows)
        {
            PagingInfo info = new PagingInfo();
            if (page.HasValue)
                info.PageIndex =page!=null?(int)page - 1:0;
            info.PageSize =rows??0;
            info.TotalRecords = 0;

            var result = new { rows = this.Scene.Bll.Test.Get<Test>(null, info).ToArray(), total = info.TotalRecords };
            return new JsonResult(result);
        }
        [Action]
        public void save(Test entity)
        {
            this.Scene.Bll.Test.Save(entity);
        }
        [Action]
        public void delete(Test entity)
        {
            this.Scene.Bll.Test.Remove(entity);
        }

        private IScene Scene
        {
            get
            {
                return MyApp.Locator.GetInstance<IUIFactory>().GetPageScene();
            }
        }
    }
}